package com.ymatou.iapi.freightservice.testcase;

import java.util.Arrays;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.Gson;
import com.ymatou.iapi.freightmanage.service.AddTemplateCall;
import com.ymatou.iapi.freightservice.parameter.OrderDto;
import com.ymatou.iapi.freightservice.parameter.OrdersDto;
import com.ymatou.iapi.freightservice.parameter.ProductDto;
import com.ymatou.iapi.freightservice.service.CalcOrderFreightCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.MapUtil;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.compare.AssertHelper;
import com.ymttest.utils.compare.LoggerHelper;
import com.ymttest.utils.compare.LoggerInterface;
import com.ymttest.utils.compare.YmtLoggerAdapter;

public class Tc_CalcOrderFreight {
	private static CalcOrderFreightCall calcOrderFreightCall = new CalcOrderFreightCall();
	private static AddTemplateCall addTemplateCall = new AddTemplateCall();
	
	private static int sellerId =7366355;
	
	//运费模板A  按件计算 首1件10元，每加一件2元 
	private static int A_Base10As1_Add2As1_AsPiece=62;

	//运费模板B   按件计算 首2件25，每加一件10元
	private static int B_Base25As2_Add10As1_AsPiece=63;
	
	//运费模板C   首重3kg，15元, 续重 每1kg 10元
	private static int C_Base15As3KG_Add10As1KG_AsWeight=64;
	
	//运费模板D   首重4kg 25元，续重 每2kg 15元
	private static int D_Base25As4KG_Add15As2KG_AsWeight=65;
	
	//运费模板E   按件计算 首1件 10元，每加一件3元
	private static int E_Base10As1_Add3As1_AsPiece=66;
	
	//运费模板F   按件计算 首1件 10元，每加一件30元
	private static int F_Base10As1_Add30As1_AsPiece=67;
		
	//运费模板G   按件计算 首1件 10元，每加3件5元
	private static int G_Base10As1_Add5As3_AsPiece=68;
	
	//运费模板H   按件计算 首1件 0元，每加1件5元
	private static int H_Base0As1_Add5As1_AsPiece=238;
	
	//运费模板I   首重4kg 0元，续重 每2kg 15元
	private static int I_Base0As4KG_Add15As2KG_AsWeight=239;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("运费模板计算");
		
		
		//结果写入xml（平台格式）的实现
		AssertHelper.setLoggerInterface(new YmtLoggerAdapter());
		
		//结果写入txt的实现
		AssertHelper.setLoggerInterface(new LoggerHelper());
		
		
		Logger.comment("创建运费模板");
		
		sellerId = TestDataManager.getRandomIntNum(7);
		
		
		
		if (EnvSetup.getEnv().equalsIgnoreCase("sit1")){
 
			A_Base10As1_Add2As1_AsPiece=62;

			B_Base25As2_Add10As1_AsPiece=63;
			
			C_Base15As3KG_Add10As1KG_AsWeight=64;
			
			D_Base25As4KG_Add15As2KG_AsWeight=65;
			
			E_Base10As1_Add3As1_AsPiece=66;
			
			F_Base10As1_Add30As1_AsPiece=67;
				
			G_Base10As1_Add5As3_AsPiece=68;
			
			H_Base0As1_Add5As1_AsPiece=238;
			
			I_Base0As4KG_Add15As2KG_AsWeight=239;
			
		}else{
			A_Base10As1_Add2As1_AsPiece=9;

			B_Base25As2_Add10As1_AsPiece=10;
			
			C_Base15As3KG_Add10As1KG_AsWeight=11;
			
			D_Base25As4KG_Add15As2KG_AsWeight=12;
			
			E_Base10As1_Add3As1_AsPiece=13;
			
			F_Base10As1_Add30As1_AsPiece=14;
				
			G_Base10As1_Add5As3_AsPiece=15;
			
			H_Base0As1_Add5As1_AsPiece=23;
			
			I_Base0As4KG_Add15As2KG_AsWeight=24;
		}
		
		
		
		
		
		
		
	
		/*try {
			A_Base10As1_Add2As1_AsPiece = addTemplateCall.callAndGetReturnData(MapUtil.hashMap("SellerId", sellerId, "Type",1, "Unit",1,
						"FirstPiece",1,"AddPiece",1,"FirstFee",10,"AddFee",2)).getJSONObject("Data").getInt("TemplateId");
			
			B_Base25As2_Add10As1_AsPiece = addTemplateCall.callAndGetReturnData(MapUtil.hashMap("SellerId", sellerId, "Type",1, "Unit",1,
					"FirstPiece",2,"AddPiece",1,"FirstFee",25,"AddFee",10)).getJSONObject("Data").getInt("TemplateId");
			
			
			
			C_Base15As3KG_Add10As1KG_AsWeight = addTemplateCall.callAndGetReturnData(MapUtil.hashMap("SellerId", sellerId, "Type",2, "Unit",2,
					"FirstWeight",3,"AddWeight",1,"FirstFee",15,"AddFee",10)).getJSONObject("Data").getInt("TemplateId");
			
			D_Base25As4KG_Add15As2KG_AsWeight = addTemplateCall.callAndGetReturnData(MapUtil.hashMap("SellerId", sellerId, "Type",2, "Unit",2,
					"FirstWeight",4,"AddWeight",2,"FirstFee",25,"AddFee",15)).getJSONObject("Data").getInt("TemplateId");
			
			
			
			E_Base10As1_Add3As1_AsPiece = addTemplateCall.callAndGetReturnData(MapUtil.hashMap("SellerId", sellerId, "Type",1, "Unit",1,
					"FirstPiece",1,"AddPiece",1,"FirstFee",10,"AddFee",3)).getJSONObject("Data").getInt("TemplateId");
			
			F_Base10As1_Add30As1_AsPiece = addTemplateCall.callAndGetReturnData(MapUtil.hashMap("SellerId", sellerId, "Type",1, "Unit",1,
					"FirstPiece",1,"AddPiece",1,"FirstFee",10,"AddFee",30)).getJSONObject("Data").getInt("TemplateId");
			
			G_Base10As1_Add5As3_AsPiece = addTemplateCall.callAndGetReturnData(MapUtil.hashMap("SellerId", sellerId, "Type",1, "Unit",1,
					"FirstPiece",1,"AddPiece",3,"FirstFee",10,"AddFee",5)).getJSONObject("Data").getInt("TemplateId");
			
			
			H_Base0As1_Add5As1_AsPiece = addTemplateCall.callAndGetReturnData(MapUtil.hashMap("SellerId", sellerId, "Type",1, "Unit",1,
					"FirstPiece",1,"AddPiece",1,"FirstFee",0,"AddFee",5)).getJSONObject("Data").getInt("TemplateId");
			
			
			I_Base0As4KG_Add15As2KG_AsWeight = addTemplateCall.callAndGetReturnData(MapUtil.hashMap("SellerId", sellerId, "Type",2, "Unit",2,
					"FirstWeight",4,"AddWeight",2,"FirstFee",0,"AddFee",15)).getJSONObject("Data").getInt("TemplateId");
			
			
		} catch (JSONException e) {
			e.printStackTrace();
		}*/
		
		
	}

	@Before
	public void caseUp() {
		
	}
	@AfterClass
	public static void tearDown() {
		Logger.generateResult(calcOrderFreightCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	

	private static OrderDto getOrderDto(List<ProductDto> productList,double totalFee){
		OrderDto orderDto = new OrderDto();
		orderDto.setSellerId(sellerId);
		//这个两个值 服务不关心 所以随机填
		orderDto.setOrderNo(TestDataManager.getRandomIntNum(10));
		orderDto.setFreightFee(totalFee);
		productList.forEach(productDto->{
			//这个两个值 服务不关心 所以随机填
			productDto.setProductId(TestDataManager.getRandomNum(10));
			productDto.setCatelogId(TestDataManager.getRandomNum(10));
		});
		
		orderDto.setProducts(productList);
		return  orderDto;
		
		
	}

	public static OrdersDto jsonToOrdersDto(JSONObject retJson) throws JSONException{
		JSONObject xx = new JSONObject();
		xx.put("orders", retJson.getJSONObject("data").getJSONArray("orders"));
		return new Gson().fromJson(xx.toString(), OrdersDto.class);
	}
		
	

	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_000_1() {
		Logger.start(true,"单种商品 按件计算  商品1件 模板H :首1件0元，每加1件5元 ");
		try {
			ProductDto productDto = new ProductDto(0,1,H_Base0As1_Add5As1_AsPiece,0);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),0);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_000_2() {
		Logger.start(true,"单种商品 按件计算  商品3件 模板H :首1件0元，每加1件5元 ");
		try {
			ProductDto productDto = new ProductDto(0,3,H_Base0As1_Add5As1_AsPiece,10);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),10);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_000_3() {
		Logger.start(true,"单种商品 按重量计算  商品1件2KG  模板I :首重4kg 0元，续重 每2kg 15元");
		try {
			ProductDto productDto = new ProductDto(2,1,I_Base0As4KG_Add15As2KG_AsWeight,0);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),0);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_000_4() {
		Logger.start(true,"单种商品 按重量计算  商品4件2KG  模板I :首重4kg 0元，续重 每2kg 15元");
		try {
			ProductDto productDto = new ProductDto(2,4,I_Base0As4KG_Add15As2KG_AsWeight,30);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),30);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_001() {
		Logger.start(true,"单种商品 按件计算  商品1件 模板A:首1件10元，每加一件2元 ");
		try {
			ProductDto productDto = new ProductDto(0,1,A_Base10As1_Add2As1_AsPiece,10);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),10);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_002() {
		Logger.start(true,"单种商品 按件计算  商品2件 模板A:首1件10元，每加一件2元 ");
		try {
			ProductDto productDto = new ProductDto(0,2,A_Base10As1_Add2As1_AsPiece,12);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),12);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_003() {
		Logger.start(true,"单种商品 按件计算  商品1件 模板B:首2件25元，每加一件10元 ");
		try {
			ProductDto productDto = new ProductDto(0,1,B_Base25As2_Add10As1_AsPiece,25);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),25);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_004() {
		Logger.start(true,"单种商品 按件计算  商品3件 模板B:首2件25元，每加一件10元 ");
		try {
			ProductDto productDto = new ProductDto(0,3,B_Base25As2_Add10As1_AsPiece,35);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),35);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_005() {
		Logger.start(true,"单种商品 按件计算  商品2件 模板G:首1件10元，每加3件5元 ");
		try {
			ProductDto productDto = new ProductDto(0,2,G_Base10As1_Add5As3_AsPiece,15);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),15);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_006() {
		Logger.start(true,"单种商品 按件计算  商品3件 模板G:首1件10元，每加3件5元");
		try {
			ProductDto productDto = new ProductDto(0,3,G_Base10As1_Add5As3_AsPiece,15);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),15);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_007() {
		Logger.start(true,"单种商品 按件计算  商品5件 模板G:首1件10元，每加3件5元");
		try {
			ProductDto productDto = new ProductDto(0,5,G_Base10As1_Add5As3_AsPiece,20);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),20);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_008() {
		Logger.start(true,"单种商品 按重量计算  商品1件2.5KG 模板C:首3KG 15元，每加1KG 10元 ");
		try {
			ProductDto productDto = new ProductDto(2.5,1,C_Base15As3KG_Add10As1KG_AsWeight,15);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),15);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_009() {
		Logger.start(true,"单种商品 按重量计算  商品1件3.1KG  模板C:首3KG 15元，每加1KG 10元 ");
		try {
			ProductDto productDto = new ProductDto(3.1,1,C_Base15As3KG_Add10As1KG_AsWeight,25);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),25);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_010() {
		Logger.start(true,"单种商品 按重量计算  商品2件1.7KG  模板C:首3KG 15元，每加1KG 10元 ");
		try {
			ProductDto productDto = new ProductDto(1.7,2,C_Base15As3KG_Add10As1KG_AsWeight,25);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto),25);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_011() {
		Logger.start(true,"多种商品; 单个模板  ;按件计算 ; A商品1件;B商品1件 ; 模板A:首1件10元，每加一件2元 ");
		try {
			ProductDto productDto1 = new ProductDto(0,1,A_Base10As1_Add2As1_AsPiece,10);
			ProductDto productDto2 = new ProductDto(0,1,A_Base10As1_Add2As1_AsPiece,2);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),12);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_012() {
		Logger.start(true,"多种商品; 单个模板  ;按件计算 ; A商品1件;B商品2件 ; 模板A:首1件10元，每加一件2元 ");
		try {
			ProductDto productDto1 = new ProductDto(0,1,A_Base10As1_Add2As1_AsPiece,10);
			ProductDto productDto2 = new ProductDto(0,2,A_Base10As1_Add2As1_AsPiece,4);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),14);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}




	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_013() {
		Logger.start(true,"多种商品; 单个模板  ;按件计算 ; A商品1件;B商品1件 ; 模板B:首2件25元，每加一件10元 ");
		try {
			ProductDto productDto1 = new ProductDto(0,1,B_Base25As2_Add10As1_AsPiece,25);
			ProductDto productDto2 = new ProductDto(0,1,B_Base25As2_Add10As1_AsPiece,10);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),35);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_013_1() {
		Logger.start(true,"多种商品; 单个模板  ;按件计算 ; A商品1件;B商品2件 ; 模板B:首2件25元，每加一件10元 ");
		try {
			ProductDto productDto1 = new ProductDto(0,1,B_Base25As2_Add10As1_AsPiece,25);
			ProductDto productDto2 = new ProductDto(0,2,B_Base25As2_Add10As1_AsPiece,20);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),45);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_014() {
		Logger.start(true,"多种商品; 单个模板  ;按件计算 ; A商品2件;B商品3件 ; 模板B:首2件25元，每加一件10元 ");
		try {
			ProductDto productDto1 = new ProductDto(0,2,B_Base25As2_Add10As1_AsPiece,25);
			ProductDto productDto2 = new ProductDto(0,3,B_Base25As2_Add10As1_AsPiece,30);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),55);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class); 
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}




	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_015() {
		Logger.start(true,"多种商品; 单个模板  ;按重量计算 ; A商品0.5KG 2个 ;B商品1KG 2个 ; 模板C:首3KG15元，每加1KG10元 ");
		try {
			ProductDto productDto1 = new ProductDto(0.5,2,C_Base15As3KG_Add10As1KG_AsWeight,15);
			ProductDto productDto2 = new ProductDto(1,2,C_Base15As3KG_Add10As1KG_AsWeight,20);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),35);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}



	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_016() {
		Logger.start(true,"多种商品; 单个模板  ;按重量计算 ; A商品0.5KG 7个 ;B商品1KG 5个 ; 模板C:首3KG15元，每加1KG10元 ");
		try {
			ProductDto productDto1 = new ProductDto(0.5,7,C_Base15As3KG_Add10As1KG_AsWeight,25);
			ProductDto productDto2 = new ProductDto(1,5,C_Base15As3KG_Add10As1KG_AsWeight,50);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),75);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_017() {
		Logger.start(true,"多个商品;同一类型多种模板; 按件计算;  [A商品 1件; 模板A:首1件10元，每加一件2元],[B商品 1件; 模板B:按件计算 首2件25，每加一件10元]");
		try {
			ProductDto productDto1 = new ProductDto(0,1,A_Base10As1_Add2As1_AsPiece,2);
			
			ProductDto productDto2 = new ProductDto(0,1,B_Base25As2_Add10As1_AsPiece,25);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),27);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}



	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_018() {
		Logger.start(true,"多个商品;同一类型多种模板; 按件计算;  [A商品 2件; 模板A:首1件10元，每加1件2元],[B商品 2件; 模板E:按件计算 首1件10，每加1件3元]");
		try {
			ProductDto productDto1 = new ProductDto(0,2,A_Base10As1_Add2As1_AsPiece,12);
			
			ProductDto productDto2 = new ProductDto(0,2,E_Base10As1_Add3As1_AsPiece,6);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),18);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_019() {
		Logger.start(true,"多个商品;同一类型多种模板; 按件计算;  [A商品 1件; 模板B:首2件25元，每加1件10元],[B商品 2件; 模板F:按件计算 首1件10，每加1件30元]");
		try {
			ProductDto productDto1 = new ProductDto(0,1,B_Base25As2_Add10As1_AsPiece,25);
			
			ProductDto productDto2 = new ProductDto(0,2,F_Base10As1_Add30As1_AsPiece,60);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),85);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_020() {
		Logger.start(true,"多个商品;同一类型多种模板; 按件计算;  [A商品 2件; 模板A:首1件10元，每加1件2元],[B商品 2件; 模板G:按件计算 首1件10，每加3件5元]");
		try {
			ProductDto productDto1 = new ProductDto(0,2,A_Base10As1_Add2As1_AsPiece,4);
			
			ProductDto productDto2 = new ProductDto(0,2,G_Base10As1_Add5As3_AsPiece,15);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),19);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_021() {
		Logger.start(true,"多个商品;同一类型多种模板; 按重量计算;  [A商品 0.5KG2个; 模板C:首3KG15元，每加1KG10元],[B商品0.5KG3个; 模板D: 首4KG25元，每加2KG15元]");
		try {
			ProductDto productDto1 = new ProductDto(0.5,2,C_Base15As3KG_Add10As1KG_AsWeight,10);
			
			ProductDto productDto2 = new ProductDto(0.5,3,D_Base25As4KG_Add15As2KG_AsWeight,25);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),35);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_022() {
		Logger.start(true,"多个商品;同一类型多种模板; 按重量计算;  [A商品 0.5KG7个, 模板C:首3KG15元，每加1KG10元],[B商品 3KG3个; 模板D: 首4KG25元，每加2KG15元]");
		try {
			ProductDto productDto1 = new ProductDto(0.5,7,C_Base15As3KG_Add10As1KG_AsWeight,40);
			
			ProductDto productDto2 = new ProductDto(3,3,D_Base25As4KG_Add15As2KG_AsWeight,70);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),110);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_023() {
		Logger.start(true,"多个商品，多个类型多种模板; [A商品 4个, 按件计算，模板G:首1件10元，每加3件5元]，[B商品 3.5KG 1个, 按件计算，模板D:首4KG25元，每加2KG15元]");
		try {
			ProductDto productDto1 = new ProductDto(0,4,G_Base10As1_Add5As3_AsPiece,10);
			
			ProductDto productDto2 = new ProductDto(3.5,1,D_Base25As4KG_Add15As2KG_AsWeight,25);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),35);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_024() {
		Logger.start(true,"多个商品，多个类型多种模板; [A商品 4个, 按件计算，模板G:首1件10元，每加3件5元]，[B商品3.5KG 2个, 按件计算，模板D:首4KG25元，每加2KG15元]");
		try {
			ProductDto productDto1 = new ProductDto(0,4,G_Base10As1_Add5As3_AsPiece,10);
			
			ProductDto productDto2 = new ProductDto(3.5,2,D_Base25As4KG_Add15As2KG_AsWeight,55);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),65);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_025() {
		Logger.start(true,"多个商品，多个类型多种模板; [A商品 3个, 按件计算，模板B:首2件25元，每加1件10元]，[B商品3.5KG 3个, 按重量计算，模板D:首4KG25元，每加2KG15元]");
		try {
			ProductDto productDto1 = new ProductDto(0,3,B_Base25As2_Add10As1_AsPiece,35);
			
			ProductDto productDto2 = new ProductDto(3.5,3,D_Base25As4KG_Add15As2KG_AsWeight,90);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),125);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_026() {
		Logger.start(true,"多个商品，多个类型多种模板; [A商品 4个, 按件计算，模板B:首2件25元，每加1件10元]，[B商品3.5KG 3个, 按重量计算，模板D:首4KG25元，每加2KG15元]");
		try {
			ProductDto productDto1 = new ProductDto(0,4,B_Base25As2_Add10As1_AsPiece,45);
			
			ProductDto productDto2 = new ProductDto(3.5,3,D_Base25As4KG_Add15As2KG_AsWeight,90);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2),135);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_027() {
		Logger.start(true,"多个商品，多个类型多种模板; [A商品 3个, 按件计算，模板B:首2件25元，每加1件10元]，[B商品3.5KG 3个, 按重量计算，模板D:首4KG25元，每加2KG15元],[C商品5个, 按件计算，模板F:首1件10元，每加1件30元]");
		try {
			ProductDto productDto1 = new ProductDto(0,3,B_Base25As2_Add10As1_AsPiece,35);
			
			ProductDto productDto2 = new ProductDto(3.5,3,D_Base25As4KG_Add15As2KG_AsWeight,90);
			
			ProductDto productDto3 = new ProductDto(0,5,F_Base10As1_Add30As1_AsPiece,150);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2,productDto3),275);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_028() {
		Logger.start(true,"多个商品，多个类型多种模板; [A商品 3个, 按件计算，模板B:首2件25元，每加1件10元]，[B商品3.5KG 3个, 按重量计算，模板D:首4KG25元，每加2KG15元],"
				+ "[C商品5个, 按件计算，模板F:首1件10元，每加1件30元],[D商品5KG3件，按重量计算 模板3：首重 3KG15元，每加1KG10元]");
		try {
			ProductDto productDto1 = new ProductDto(0,3,B_Base25As2_Add10As1_AsPiece,35);
			
			ProductDto productDto2 = new ProductDto(3.5,3,D_Base25As4KG_Add15As2KG_AsWeight,90);
			
			ProductDto productDto3 = new ProductDto(0,5,F_Base10As1_Add30As1_AsPiece,150);
			
			ProductDto productDto4 = new ProductDto(5,3,C_Base15As3KG_Add10As1KG_AsWeight,150);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2,productDto3,productDto4),425);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_029() {
		Logger.start(true,"多个商品，多个类型多种模板,有一个商品没对应模板; [A商品 3个, 按件计算，模板B:首2件25元，每加1件10元]，[B商品3.5KG 3个, 按重量计算，模板D:首4KG25元，每加2KG15元],"
				+ "[C商品5个, 按件计算，模板F:首1件10元，每加1件30元],[D商品5KG3件，按重量计算 模板3：首重 3KG15元，每加1KG10元]");
		try {
			ProductDto productDto1 = new ProductDto(0,3,B_Base25As2_Add10As1_AsPiece,35);
			
			ProductDto productDto2 = new ProductDto(3.5,3,D_Base25As4KG_Add15As2KG_AsWeight,90);
			
			ProductDto productDto3 = new ProductDto(0,5,F_Base10As1_Add30As1_AsPiece,150);
			
			ProductDto productDto4 = new ProductDto(5,3,C_Base15As3KG_Add10As1KG_AsWeight,150);
			
			ProductDto productDto5 = new ProductDto(5,3,1231233,0);
			
			OrderDto orderDto =getOrderDto(Arrays.asList(productDto1,productDto2,productDto3,productDto4,productDto5),425);
			
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(new OrdersDto(Arrays.asList(orderDto)));
			
			
			OrderDto actOrder = new Gson().fromJson(ret.getJSONObject("data").getJSONArray("orders").get(0).toString(),OrderDto.class);
			
			AssertHelper.assertResultEqual(orderDto, actOrder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_030() {
		Logger.start(true,"多个订单  多个商品，多个类型多种模板 订单A:case 27"
				+ "订单B case 28");
		try {
			ProductDto productDto1 = new ProductDto(0,3,B_Base25As2_Add10As1_AsPiece,35);
			
			ProductDto productDto2 = new ProductDto(3.5,3,D_Base25As4KG_Add15As2KG_AsWeight,90);
			
			ProductDto productDto3 = new ProductDto(0,5,F_Base10As1_Add30As1_AsPiece,150);
			
			OrderDto orderDto1 =getOrderDto(Arrays.asList(productDto1,productDto2,productDto3),275);
			
			
			
			ProductDto productDto2_1 = new ProductDto(0,3,B_Base25As2_Add10As1_AsPiece,35);
			
			ProductDto productDto2_2 = new ProductDto(3.5,3,D_Base25As4KG_Add15As2KG_AsWeight,90);
			
			ProductDto productDto2_3 = new ProductDto(0,5,F_Base10As1_Add30As1_AsPiece,150);
			
			ProductDto productDto2_4 = new ProductDto(5,3,C_Base15As3KG_Add10As1KG_AsWeight,150);
			
			ProductDto productDto2_5 = new ProductDto(5,3,1231233,0);
			
			OrderDto orderDto2 =getOrderDto(Arrays.asList(productDto2_1,productDto2_2,productDto2_3,productDto2_4,productDto2_5),425);
			
			OrdersDto tgtOrdersDto = new OrdersDto(Arrays.asList(orderDto1,orderDto2));
			JSONObject ret = calcOrderFreightCall.calcOrderFreight(tgtOrdersDto);
			
			
			JSONObject actJSON = new JSONObject();
			actJSON.put("orders", ret.getJSONObject("data").getJSONArray("orders"));
			OrdersDto actOrsder = new Gson().fromJson(actJSON.toString(),OrdersDto.class);
			
			AssertHelper.assertResultEqual(tgtOrdersDto, actOrsder, "运费计算检查");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
}
